package game.players.states;

import java.util.Timer;

import utils.tasks.FinishBeatenTask;

import com.uqbar.vainilla.DeltaState;

import game.players.SoccerPlayer;

public abstract class BeatenPlayer extends PlayerState {
	
	private boolean isRight;
	private FinishBeatenTask timerTask = new FinishBeatenTask(this);

	public BeatenPlayer(SoccerPlayer player, boolean isRight) {
		super(player);
		this.setRight(isRight);
		this.setAnimation();
		
		Timer timer = new Timer();
		timer.schedule(this.getTimerTask(), 3000);
	}

	private void setAnimation() {
		if (this.isRight())
			this.setRightSprite();
		else
			this.setLeftSprite();
	}
	
	@Override
	public void update(DeltaState deltaState) {
		if (this.isRight())
			this.getPlayer().move(0.1, 0);
		else
			this.getPlayer().move(-0.1, 0);
	}
	
	public abstract void finishBeaten();
	
	public abstract void setRightSprite();
	
	public abstract void setLeftSprite();
	
	
	
	
	
	

	public FinishBeatenTask getTimerTask() {
		return timerTask;
	}

	@Override
	public boolean isRight() {
		return isRight;
	}

	public void setRight(boolean isRight) {
		this.isRight = isRight;
	}

}
